﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoogleMapsApiWebServices.Core;

namespace GoogleMapsApiWebServices.Geocoding
{
    public class GeocodingRequest : MapsApiRequest
    {
        protected override string BaseUri { get { return @"http://maps.googleapis.com/maps/api/geocode"; } }

        [QueryStringParameter(IsRequired = false, QueryStringParameter = "address")]
        public string Address { get; set; }

        [QueryStringParameter(IsRequired = false, QueryStringParameter = "latlng")]
        public Coordinate LatLong { get; set; }

        [QueryStringParameter(IsRequired = false, QueryStringParameter = "bounds")]
        public BoundingBox Bounds { get; set; }

        [QueryStringParameter(IsRequired = false, QueryStringParameter = "language")]
        public string Language { get; set; }

        [QueryStringParameter(IsRequired = false, QueryStringParameter = "region")]
        public string Region { get; set; }

        protected override void ValidateRequest()
        {
            if (String.IsNullOrWhiteSpace(Address) && LatLong.Latitude == 0 && LatLong.Longitude == 0)
                throw new ValidationException();
        }
    }
}
